import unittest, requests


class Weidu(unittest.TestCase):
    def setUp(self) -> None:
        print('start case')

    def tearDown(self) -> None:
        print('end case')

    # 登录
    userId = None
    sessionId = None
    phone = None

    def test_Weidu_01(self):
        r1 = requests.post(url='http://10.59.9.18/health/user/v1/login',
                           params={"email": "3500186206@qq.com",
                                   "pwd": "lZjdXyj15cOhn1a0yJKsW7o+fw/ogBDzn6CcyPSJUVIMmCPtCs+zuPwh7IZkXZiRhJvvjdIz9D2z1jkMOtD/36ddaLFMtQd9xIk0jAaDP1TH/lEHvvUPwot6asMGMGkH9EgBPT+4eaYC77BGQBPOASweQZE5KDF8BeN/c0sLfSw="})

        print(r1.json())
        # 提取userId sessionId
        Weidu.userId = str(r1.json()['result']['userId'])
        Weidu.sessionId = str(r1.json()['result']['sessionId'])
        print(Weidu.userId)
        print(Weidu.sessionId)

    # 查询问诊医生列表
    doctorId = None

    def test_Weidu_02(self):
        r2 = requests.get(url='http://10.59.9.18/health/user/inquiry/v1/findDoctorList',
                          params={"deptId": 2, 'condition': 2, 'sortBy': 1, 'page': 1, 'count': 5})
        print(r2.json())
        # 提取 doctorId
        Weidu.doctorId = r2.json()['result'][0]['doctorId']
        print('doctorId：', Weidu.doctorId)

    # 根据关键词查询病友圈
    sickCircleId=None
    def test_Weidu_03(self):
        r3 = requests.get(url='http://10.59.9.18/health/user/sickCircle/v1/searchSickCircle',
                          params={"keyWord": '头疼'})
        print(r3.json())
        # 提取 sickCircleId
        Weidu.sickCircleId=r3.json()['result'][0]['sickCircleId']
        print(Weidu.sickCircleId)

    # 查询病友圈详情
    departmentId=None
    def test_Weidu_04(self):
        r4 = requests.get(url='http://10.59.9.18/health/user/sickCircle/v1/findSickCircleInfo',
                          headers={"userId": str(Weidu.userId), 'sessionId': str(Weidu.sessionId)},
                          params={'sickCircleId': Weidu.sickCircleId})
        print(r4.json())
        # 提取 departmentId
        Weidu.departmentId=r4.json()['result']['departmentId']
        print(Weidu.departmentId)

    # 病友圈列表展示

    def test_Weidu_05(self):
        r5 = requests.get(url='http://10.59.9.18/health/doctor/sickCircle/v1/findSickCircleList',
                          params={'departmentId': Weidu.departmentId,'page':2,'count':5})
        print(r5.json())

    # 病友圈发表评论
    def test_Weidu_06(self):
        r5 = requests.post(url='http://10.59.9.18/health/user/sickCircle/verify/v1/publishComment',
                          headers={"userId": str(Weidu.userId), 'sessionId': str(Weidu.sessionId)},
                          data={'sickCircleId': Weidu.sickCircleId, 'content': 'aa'})
        print(r5.json())



if __name__ == '__main__':
    # 第一种方式
    unittest.main()
